<!DOCTYPE html>
<html lang="en">
<head>
    <title>公司管理层</title>
    <meta http-equiv="pragma" content="no-cache">
    <meta http-equiv="Cache-Control" content="no-store, must-revalidate">
    <meta http-equiv="expires" content="Wed, 26 Feb 1997 08:21:57 GMT">
    <meta http-equiv="expires" content="-1">
    <meta content="width=device-width, initial-scale=1, maximum-scale=1, user-scalable=no"
          name="viewport">
    <meta http-equiv="X-UA-Compatible" content="IE=edge">
    <meta charset="utf-8">
    <meta name="viewport" content="width=device-width, initial-scale=1">
    <link rel="shortcut icon" href="/dist/img/icon.png" type="image/x-icon">
    <script src="https://file.ggxqce.com/web/vue.min.js"></script>

    <style>
        [v-cloak] {
            display: none;
        }

        * {
            -webkit-box-sizing: border-box;
            -moz-box-sizing: border-box;
            box-sizing: border-box;
            font-size: 12px;
        }

        body {
            margin: 1px;
            background: #f8f8f8;
        }

        table {
            border-spacing: 0;
            border-collapse: collapse;
            display: table;
        }

        table.text-center, table.text-center td, table.text-center th {
            text-align: center;
            font-size: 12px;
        }

        .table-bordered > thead > tr > th, .table-bordered > tbody > tr > th, .table-bordered > tfoot > tr > th, .table-bordered > thead > tr > td, .table-bordered > tbody > tr > td, .table-bordered > tfoot > tr > td {
            border: 1px solid #cbcbcd;
            font-weight: normal;
            height: 24px;
        }

        .table th {
            background: yellow;
        }

        .table-bordered {
            border: 1px solid #cbcbcd;
        }

        .table {
            width: 100%;
            max-width: 100%;
        }

        .hidden {
            display: none;
        }

        .lineOne {
            text-align: left;
        }

        .lineOne span {
            max-height: 24px;
            line-height: 24px;
            overflow: hidden;
            text-overflow: ellipsis;
            display: -webkit-box;
            -webkit-box-orient: vertical;
            -webkit-line-clamp: 1;
            text-align: left;
        }

        .mScrollBox {
            float: left;
            position: relative;
            overflow: hidden;
        }

        .infoReport {
            text-align: center;
            margin: 0;
            margin-bottom: 10px;
        }

        .moduleName {
            height: 20px;
            line-height: 20px;
            background: #f8f8f8;
            font-weight: bold;
            font-size: 14px;
        }

        .oaReportNav {
            position: relative;
        }

        .toggleDiv {
            height: 20px;
            line-height: 20px;
            margin-bottom: 10px;
        }

        .toggleDiv div {
            width: 50%;
            float: left;
            text-align: center;
        }

        .toggleDiv div.active {
            border-bottom: 2px solid #2289ee;
        }

        .div-td-content-more {
            position: absolute;
            height: auto;
            z-index: 999;
            line-height: 20px;
            background-color: #d3e8fd;
            padding: 8px 6px;
            border: 1px solid #e8e8ea;
            display: none;
        }

        .div-td-content-more i {
            width: 15px;
            height: 12px;
            background: url("/dist/img/more-icon.png");
            position: absolute;
            left: 50px;
            top: -12px;
        }
    </style>
</head>
<body>
<section class="content" id="app" v-cloak>
    <div class="div-td-content-more"><i></i></div>
    <div style="background: #fff;overflow: hidden;" id="interviewCompany">
        <div style="width: 100%;" class="mScrollBox">
            <table class="table table-bordered text-center table-width">
                <thead>
                <tr>
                    <th style="width:10%;">面访<br>排名
                    </th>
                    <th style="width:12%;">人均<br>完成
                    </th>
                    <th style="width:12%;" v-if="visitCustomer.time.length==10">大区</th>
                    <th style="width:18%;" v-else>大区</th>
                    <th style="width:12%;" v-if="visitCustomer.time.length==10">大区<br>经理</th>
                    <th style="width:15%;" v-else>大区经理</th>
                    <th style="width:11%;">目标
                    </th>
                    <th style="width:11%;">完成
                    </th>
                    <th style="width:12%;">完成率</th>
                    <th style="width:10%;">在职<br>人数</th>
                    <th style="width:10%;" v-if="visitCustomer.time.length==10">请假<br>人数</th>
                    <!--<th style="width:10%;">区域经理<br>标配人数</th>-->
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item,i) in visitCustomer.faceList">
                    <td>{{item.rownum}}</td>
                    <td>{{item.averageComplete}}</td>
                    <td style="text-align:center;color:#2a8cec;cursor: pointer"
                        @click="lookInterviewDepart(item),'1'" class="lineOne"><span
                            style="text-align:center;">{{item.departName}}</span>
                    </td>
                    <td>
                        <span v-if="item.bigManagerName">{{item.bigManagerName}}</span>
                        <span v-else style="color: #CCCCCC;">空缺</span>
                    </td>
                    <td>{{item.target}}</td>
                    <td>{{item.complete}}</td>
                    <td v-if="item.completionRate!=''&&item.completionRate!='-'">{{item.completionRate}}%</td>
                    <td v-else>{{item.completionRate}}</td>
                    <td>{{item.regionManagerNum}}</td>
                    <td v-if="visitCustomer.time.length==10">{{item.leaveNumber}}</td>
                    <!--<td>{{item.managerTargetNum}}</td>-->
                </tr>
                <tr>
                    <td>合计</td>
                    <td>{{visitCustomer.bigcalculation[1].daily}}</td>
                    <td>-</td>
                    <td>-</td>
                    <td>{{visitCustomer.bigcalculation[1].targetDayCount}}</td>
                    <td>{{visitCustomer.bigcalculation[1].finishDayCount}}</td>
                    <td>-</td>
                    <td>{{visitCustomer.bigcalculation[1].regionManagerNum}}</td>
                    <td v-if="visitCustomer.time.length==10">
                        {{visitCustomer.bigcalculation[1].leaveNumber}}
                    </td>
                    <!--<td>{{visitCustomer.bigcalculation[1].managerTargetNum}}</td>-->
                </tr>
                </tbody>
            </table>
        </div>
        <div style="width: 100%;margin-top: 10px;" class="mScrollBox">
            <table class="table table-bordered text-center table-width">
                <thead>
                <tr>
                    <th style="width:10%;">电访<br>排名
                    </th>
                    <th style="width:12%;">人均<br>完成
                    </th>
                    <th style="width:12%;" v-if="visitCustomer.time.length==10">大区</th>
                    <th style="width:18%;" v-else>大区</th>
                    <th style="width:12%;" v-if="visitCustomer.time.length==10">大区<br>经理</th>
                    <th style="width:15%;" v-else>大区经理</th>
                    <th style="width:11%;">目标
                    </th>
                    <th style="width:11%;">完成
                    </th>
                    <th style="width:12%;">完成率</th>
                    <th style="width:10%;">在职<br>人数</th>
                    <th style="width:10%;" v-if="visitCustomer.time.length==10">请假<br>人数</th>
                    <!--<th style="width:10%;">区域经理<br>标配人数</th>-->
                </tr>
                </thead>
                <tbody>
                <tr v-for="(item,i) in visitCustomer.telList">
                    <td>{{item.rownum}}</td>
                    <td>{{item.averageComplete}}</td>
                    <td style="color:#2a8cec;cursor: pointer" @click="lookInterviewDepart(item),'0'"
                        class="lineOne"><span style="text-align:center;">{{item.departName}}</span>
                    </td>
                    <td>
                        <span v-if="item.bigManagerName">{{item.bigManagerName}}</span>
                        <span v-else style="color: #CCCCCC;">空缺</span>
                    </td>
                    <td>{{item.target}}</td>
                    <td>{{item.complete}}</td>
                    <td v-if="item.completionRate!=''&&item.completionRate!='-'">{{item.completionRate}}%</td>
                    <td v-else>{{item.completionRate}}</td>
                    <td>{{item.regionManagerNum}}</td>
                    <td v-if="visitCustomer.time.length==10">{{item.leaveNumber}}</td>
                    <!--<td>{{item.managerTargetNum}}</td>-->
                </tr>
                <tr>
                    <td>合计</td>
                    <td>{{visitCustomer.bigcalculation[0].daily}}</td>
                    <td>-</td>
                    <td>-</td>
                    <td>{{visitCustomer.bigcalculation[0].targetDayCount}}</td>
                    <td>{{visitCustomer.bigcalculation[0].finishDayCount}}</td>
                    <td>-</td>
                    <td>{{visitCustomer.bigcalculation[0].regionManagerNum}}</td>
                    <td v-if="visitCustomer.time.length==10">
                        {{visitCustomer.bigcalculation[0].leaveNumber}}
                    </td>
                    <!--<td>{{visitCustomer.bigcalculation[0].managerTargetNum}}</td>-->
                </tr>
                </tbody>
            </table>
        </div>
    </div>

    <!-- /.box-body -->
</section>
<!--JQ-->
<script src="https://file.ggxqce.com/web/jquery-2.2.3.min.js"></script>
<!--插件JS-->
<script src="/dist/plugins/scroll/myScroll.js"></script>
<!--框架已定义 JS-->
<!--oa自定义  JS-->
<script src="/dist/js/oaApp.js"></script>

<script type="text/javascript" src="/dist/plugins/lhgdialog/lhgdialog.min.js?self=true"></script>
<script>
    $(function () {
        $("body").on("click", ".lineOne", function (e) {
            if ($(".div-td-content-more").is(":hidden")) {
                var text = $(this).text();
                if (text != "") {
                    text = "<i></i>" + text;
                    $(".div-td-content-more").html(text).css({
                        "width": $(this).outerWidth() + "px",
                        "left": $(this).offset().left,
                        "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                    }).show();
                    e.stopPropagation();
                }
            } else {
                $(".div-td-content-more").hide();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });
</script>
<script>
    $.ajaxSetup({
        global: true,
        type: "POST",
        cache: false,
        dataType: "json",
        contentType: 'application/json;charset=utf-8',
        beforeSend: function () {
        },
        complete: function () {

        },
        error: function (e) {
            alert('error' + e.responseText);
        }
    });
    $.extend($.wyui, {
        postMethod: function (url, data, callback, sync, id) {
            if (!id) {
                id = "#app"
            }
            $.ajax({
                url: server.ip + url,
                async: sync ? false : true,
                data: JSON.stringify(data),
                beforeSend: function () {

                },
                complete: function () {
                    setTimeout(function () {
                    }, 1000);

                },
                success: function (r) {
                    if (!r.e.code) {
                        callback(r.data.sendData);
                    } else {
                        alert(r.e.desc);
                    }
                },
                error: function (e) {
                    alert(url + e.responseText);
                }
            });
        },
    });
</script>
<script type="text/javascript">
    $(function () {
        $("body").on("click", ".reginTd", function (e) {
            var text = $(this).text();
            if (text != "") {
                text = "<i></i>" + text;
                $(".div-td-content-more").html(text).css({
                    "width": $(this).outerWidth() + "px",
                    "left": $(this).offset().left,
                    "top": ($(this).offset().top + $(this).outerHeight()) + "px"
                }).show();
                e.stopPropagation();
            }
        });
        $("body").on("click", ".div-td-content-more", function (e) {
            e.stopPropagation();
        });
        $("body").on("click", function () {
            $(".div-td-content-more").hide();
        });
    });

</script>
<script type="text/javascript">
    console.log(urlConfig);
    var app = new Vue({
        el: '#app',
        data: {
            userId: getCurrentUser().userId,
            companyId: getCurrentUser().companyId,
            months: [],
            dateTime: getCurrentUser().dateTime,
            yesterday:new Date(new Date()-24*60*60*1000).Format("yyyy-MM-dd"),
            today: new Date().Format("yyyy-MM-dd"),
            thisMonth: new Date().Format("yyyy-MM"),
            thisWeek: new Date().Format("yyyy-MM-dd") + "-w",
            hour: new Date().getHours(),
            tab: [],
            visitCustomer: {
                time: getCurrentUser().dateTime,
                faceList: [],
                telList: [],
                bigcalculation: [{
                    "targetDayCount": 0,
                    "finishDayCount": 0,
                    "regionNumber": 0,
                    "daily": 0,
                    "completionRate": 0
                }, {
                    "targetDayCount": 0,
                    "finishDayCount": 0,
                    "regionNumber": 0,
                    "daily": 0,
                    "completionRate": 0,
                    'leaveNumber': 0
                }]
            },
            calculation: [{
                "targetDayCount": 0,
                "finishDayCount": 0,
                "regionNumber": 0,
                "daily": 0,
                "completionRate": 0
            }, {
                "targetDayCount": 0,
                "finishDayCount": 0,
                "regionNumber": 0,
                "daily": 0,
                "completionRate": 0,
                'leaveNumber': 0
            }],
        },
        methods: {
            //tab中点击日期刷新对应数据
            refreshData: function (dataType, fun, time) {
                var that = this;
                that[dataType].time = time;
                that[fun]();
            },
            //获取tab
            getTab: function () {
                var that = this;
                var dateTime = new Date().Format("yyyyMM");

                for (var i = 0; i < 5; i++) {
                    dateTime = that.getLastEndMonth(dateTime);
                    that.tab.push(that.insert_flg(dateTime, "-", "4"))
                }
                console.log(that.tab)
            },
            isActive: function (item) {
                var that = this;
                if (that.visitCustomer.time == item) {
                    return true;
                }
            },
            getLastEndMonth: function (beginYearMonth) {
                var strYear = parseInt(beginYearMonth.substr(0, 4), 10);
                var strMonth = parseInt(beginYearMonth.substr(4, 6), 10);
                if (strMonth - 1 == 0) {
                    strYear -= 1;
                    strMonth = 12;
                } else {
                    strMonth -= 1;
                }
                if (strMonth < 10) {
                    strMonth = "0" + strMonth;
                }
                var monthstr = strYear + "" + strMonth;
                return monthstr;
            },
            //格式化日期
            insert_flg: function (str, flg, sn, type) {
                var newstr = "";
                for (var i = 0; i < str.length; i += sn) {
                    var tmp = str.substring(i, i + sn);
                    newstr += tmp + flg;
                }
                newstr = newstr.substr(0, newstr.length - 1);
                var st1 = newstr.substr(2, 2);
                var st2 = newstr.substr(5, 2);
                var newstr3 = st2 + "/" + st1;
                var obj = {str: newstr3, time: newstr};
                return obj;
            },
            getCount: function (arr, key) {
                var number = 0;
                for (var i = arr.length - 1; i >= 0; i--) {
                    number += (arr[i][key]&&arr[i][key]!='-'? arr[i][key] : 0)

                }
                return number;
            },
            getAllCounnt: function (arr, type) {
                if (type == "1") {
                    this.calculation[1].targetDayCount = this.getCount(arr, "target");
                    this.calculation[1].finishDayCount = this.getCount(arr, "complete");
                    this.calculation[1].managerTargetNum = this.getCount(arr, "managerTargetNum");
                    this.calculation[1].regionManagerNum = this.getCount(arr, "regionManagerNum");
                    this.calculation[1].leaveNumber = this.getCount(arr, "leaveNumber");
                    this.calculation[1].daily = (this.calculation[1].finishDayCount / this.calculation[1].regionManagerNum).toFixed(2);
                    if (this.calculation[1].targetDayCount == 0) {
                        this.calculation[1].completionRate = "0.00%";
                    } else {
                        this.calculation[1].completionRate = (this.calculation[1].finishDayCount / this.calculation[1].targetDayCount * 100).toFixed(2) + "%";
                    }
                } else {
                    this.calculation[0].targetDayCount = this.getCount(arr, "target");
                    this.calculation[0].finishDayCount = this.getCount(arr, "complete");
                    this.calculation[0].managerTargetNum = this.getCount(arr, "managerTargetNum");
                    this.calculation[0].regionManagerNum = this.getCount(arr, "regionManagerNum");
                    this.calculation[0].leaveNumber = this.getCount(arr, "leaveNumber");
                    this.calculation[0].daily = (this.calculation[0].finishDayCount / this.calculation[0].regionManagerNum).toFixed(2);
                    if (this.calculation[0].targetDayCount == 0) {
                        this.calculation[0].completionRate = "0.,l00%";
                    } else {
                        this.calculation[0].completionRate = (this.calculation[0].finishDayCount / this.calculation[0].targetDayCount * 100).toFixed(2) + "%";
                    }
                }
                console.log(this.calculation)
            },
            get_visitCompany: function () {
                var that = this;
                $.wyui.postMethod(urlConfig.report.visitCustomer.getForDepart, {
                    "userId":that.userId,
                    "companyId": that.companyId,
                    "dateTime": that.visitCustomer.time,
                    "type": "1"
                }, function (data) {
                    var data=trimRN2(data);
                    that.visitCustomer.faceList = data;
                    //获取合计
                    that.visitCustomer.bigcalculation[1].targetDayCount = that.getCount(that.visitCustomer.faceList, "target");
                    that.visitCustomer.bigcalculation[1].finishDayCount = that.getCount(that.visitCustomer.faceList, "complete");
                    that.visitCustomer.bigcalculation[1].managerTargetNum = that.getCount(that.visitCustomer.faceList, "managerTargetNum");
                    that.visitCustomer.bigcalculation[1].regionManagerNum = that.getCount(that.visitCustomer.faceList, "regionManagerNum");
                    that.visitCustomer.bigcalculation[1].leaveNumber = that.getCount(that.visitCustomer.faceList, "leaveNumber");
                    that.visitCustomer.bigcalculation[1].daily = (that.visitCustomer.bigcalculation[1].finishDayCount / that.visitCustomer.bigcalculation[1].regionManagerNum).toFixed(2);
                    if (that.visitCustomer.bigcalculation[1].targetDayCount == 0) {
                        that.visitCustomer.bigcalculation[1].completionRate = "0.00%";
                    } else {
                        that.visitCustomer.bigcalculation[1].completionRate = (that.visitCustomer.bigcalculation[1].finishDayCount / that.visitCustomer.bigcalculation[1].targetDayCount * 100).toFixed(2) + "%";
                    }
                }, false, "#visitCompany");
                $.wyui.postMethod(urlConfig.report.visitCustomer.getForDepart, {
                    "userId":that.userId,
                    "companyId": that.companyId,
                    "dateTime": that.visitCustomer.time,
                    "type": "0"
                }, function (data) {
                    var data=trimRN2(data);
                    that.visitCustomer.telList = data;
                    //获取合计
                    that.visitCustomer.bigcalculation[0].targetDayCount = that.getCount(that.visitCustomer.telList, "target");
                    that.visitCustomer.bigcalculation[0].finishDayCount = that.getCount(that.visitCustomer.telList, "complete");
                    that.visitCustomer.bigcalculation[0].managerTargetNum = that.getCount(that.visitCustomer.telList, "managerTargetNum");
                    that.visitCustomer.bigcalculation[0].regionManagerNum = that.getCount(that.visitCustomer.telList, "regionManagerNum");
                    that.visitCustomer.bigcalculation[0].leaveNumber = that.getCount(that.visitCustomer.telList, "leaveNumber");
                    that.visitCustomer.bigcalculation[0].daily = (that.visitCustomer.bigcalculation[0].finishDayCount / that.visitCustomer.bigcalculation[0].regionManagerNum).toFixed(2);
                    if (that.visitCustomer.bigcalculation[0].targetDayCount == 0) {
                        that.visitCustomer.bigcalculation[0].completionRate = "0.,l00%";
                    } else {
                        that.visitCustomer.bigcalculation[0].completionRate = (that.visitCustomer.bigcalculation[0].finishDayCount / that.visitCustomer.bigcalculation[0].targetDayCount * 100).toFixed(2) + "%";
                    }
                }, false, "#visitCompany");

            },
            //查拜访公司下级页面
            lookInterviewDepart: function (item, type) {
                var that = this;
                var obj = {
                    type: 'depart',
                    url: '/reportForm/interview/interviewDepartApp.html?companyId=%1s&departName=%2s&dateTime=%3s',
                    id: item.companyId,
                    name: item.departName,
                    dateTime: that.visitCustomer.time
                }
                prompt(JSON.stringify(obj))
//                url = "reportForm/interview/interviewDepart.html";
//                top.closeTabByPageId("lookInterviewDepart");
//                top.addTabs({id:"lookInterviewDepart",title:item.departName,close: true,url:url+ '?companyId=' +item.companyId+"&dateTime="+that.visitCustomer.time});
            },
        },
        mounted: function () {
            var that = this;
            //获取前5个月 拼接出日期筛选框
            //查看参数
            if (!that.companyId) {
                that.companyId = getCurrentUser().companyId;
            }
            if (!that.dateTime) {
                that.dateTime = new Date().Format("yyyy-MM-dd");
            }
            //获取前5个月的tab数据
            this.getTab();
            //获取数据
            that.get_visitCompany();
        }

    });
</script>
</body>
</html>